% from cov_party_affil.csv in BESIP/data/
covarmat = [.0816675	-.0077852	-.069981	.0102395	.0356826
    -.0077852	.0792458	-.0676872	.0145195	.0325168
    -.069981	-.0676872	.171587	-.0225283	-.0628361
    .0102395	.0145195	-.0225283	.0486676	-.0063273
    .0356826	.0325168	-.0628361	-.0063273	.1081279];

DVlabels= {'Duty to Vote'
    'Satisfied w/ UK Democracy'
    'Trust MPs'
    'Efficacy: Understand'
    'Efficacy: Pol Care' };

varOfDV = [4.771
    13.033
    13.237
    11.457
    16.759];

coefs = [0.329	0.331	0.419	0.223	0.189
    0.317	0.084	0.354	0.116	0.106
    0.231	-0.199	0.057	0.107	0.025
    0.214	0.104	0.574	0.699	0.239
    0.129	-0.023	0.241	0.344	0.063];

dummyLabels = {'conservative_party'
    'labour_party'
    'other_party'
    'strong_partyidstrength'
    'fstrong_partyidstrength' };

varOfAll = NaN(5, 1);
for dvIx = 1:5
    betaHere = coefs(:, dvIx);
    varOfAll(dvIx) = betaHere' * covarmat * betaHere;
end

varOfIdOnly = NaN(5, 1);
for dvIx = 1:5
    betaHere = coefs(1:3, dvIx);
    varOfIdOnly(dvIx) = betaHere' * covarmat(1:3, 1:3) * betaHere;
end

varOfStrengthOnly = NaN(5, 1);
for dvIx = 1:5
    betaHere = coefs(4:5, dvIx);
    varOfStrengthOnly(dvIx) = betaHere' * covarmat(4:5, 4:5) * betaHere;
end

varOfExplainatory = [ 1.250
    5.154
    5.107
    4.425
    6.676];

tabAbs = table(DVlabels, varOfDV, varOfExplainatory, varOfAll, varOfIdOnly, varOfStrengthOnly)

shareAll = 100.0 * varOfAll./varOfDV;
shareId = 100.0 * varOfIdOnly./varOfDV;
shareStrength = 100.0 * varOfStrengthOnly./varOfDV;
tabPercentShareTotal = table(DVlabels, shareAll, shareId, shareStrength)

shareAll = 100.0 * varOfAll./varOfExplainatory;
shareId = 100.0 * varOfIdOnly./varOfExplainatory;
shareStrength = 100.0 * varOfStrengthOnly./varOfExplainatory;
tabPercentShareExplainatory = table(DVlabels, shareAll, shareId, shareStrength)


% tabAbs = table(DVlabels, varOfDV, varOfExplainatory, varOfAll, varShareOfAll, varOfIdOnly, varShareOfIdOnly, varOfStrengthOnly, varShareOfStrengthOnly)